xen: credit2: fix two s_time_t handling issues in load balancing
authorDario Faggioli <dario.faggioli@citrix.com>
Wed, 20 Jul 2016 09:50:12 +0000 (10:50 +0100)
committerGeorge Dunlap <george.dunlap@citrix.com>
Wed, 20 Jul 2016 10:08:34 +0000 (11:08 +0100)
commitb5b5876619bd8ec2e3b8eb4d6a11acee71592eae
tree445ee255bb3dd5f4f3f3df49dd853601249c88f0
parent9bb9c73884d991d43f8973bdda6e45f113dfe6ca
xen: credit2: fix two s_time_t handling issues in load balancing

both introduced in d205f8a7f48e2ec ("xen: credit2: rework
load tracking logic").

First, in __update_runq_load(), the ASSERT() was actually
useless. Let's instead check that the computed value of
the load has not overflowed (and hence gone negative).

While there, do that in __update_svc_load() as well.

Second, in balance_load(), cpus_max needs being extended
in order to be correctly shifted, and the result compared
with an s_time_t value, without risking loosing info.

Spotted by Coverity.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
xen/common/sched_credit2.c